/*
 * HackSQL
 * Copyright (C) 2008-2009
 *
 * Authors: Higor Eurípedes Pimentel Fernandes de Araújo
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * $Id: utils.h 57 2009-06-07 02:46:25Z heuripedes $
 */

#ifndef __UTILS_H__
#define __UTILS_H__

#include <stdarg.h>
#include "types.h"

/*
 * Checks if 'e' exists, if not set 'v' to 'd'
 */
#define hs_getenv(v, e, d) \
	v = getenv(e); \
	if (!v || !*v) { \
		v = d; \
	}

inline void *get_in_addr(struct sockaddr *sa);

/*
 * Some string functions
 */
char *trimstr(char *string);
char **tokenize(char *str, char *delimiters, int *num);
void hs_error(hs_errno code, char *format, ...);
void hs_warning(char *format, ...);
char *getfilecontents(char *filename);
long int getfilesize(char *filename);

#endif				/* __UTILS_H__ */
